package com.tjn.map;

import java.util.Properties;

/**
 * @author 陶镓妮
 * @version 1.0
 */
public class Properties_ {
    @SuppressWarnings("all")
    public static void main(String[] args) {
        /*
        properties类继承HashTable类，实现Map接口，
        是键值对k-v的形式保存数据，使用特点和HashTable相类似
        它还可以用于从.properties文件中加载数据到Properties类对象，并进行读取和修改
        key和value不能为null，会抛出异常,有相同的key，value被替换
         */

        Properties properties = new Properties();
        //properties.put(null,"周一");//异常
        properties.put("two","周二");
        //properties.put("three",null);//异常
        properties.put("four","周四");
        properties.put("five","周五");
        properties.put("five","周六");//替换

        System.out.println(properties);

        //get()通过key获取对应值
        System.out.println(properties.get("two"));

        //remove()删除
        System.out.println(properties.remove("five"));
        System.out.println(properties);

    }
}
